<template>
  <el-card>
    <el-table
      v-loading="loading"
      :header-cell-style="{background:'#eef1f6',color:'#606266'}"
      :data="tableData"
      border
      :stripe="true"
      style="width: 100%;"
    >
      <el-table-column
        prop="createTime"
        :label="tableText['createTime']"
        min-width="170"
      />
      <el-table-column
        prop="stageId"
        :label="tableText['stage']"
        min-width="120"
      />
      <el-table-column
        prop="overdueDay"
        :label="tableText['days']"
        min-width="120"
      />
      <el-table-column
        prop="staffName"
        :label="tableText['allot']"
        min-width="170"
      />
      <el-table-column
        prop="operatorName"
        :label="tableText['operator']"
        min-width="170"
      />
    </el-table>
    <div class="block">
      <el-pagination
        :current-page="searchForm.currentPage"
        :page-sizes="[10, 20, 30, 40, 50]"
        :page-size="searchForm.pageSize"
        :total="totalNumber"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </el-card>
</template>

<script>
import { queryFlowHistory } from '@/api/collection'
export default {
  name: 'CollectionFlow',
  data() {
    return {
      loading: true,
      tableText: {},
      totalNumber: 0,
      tableData: [],
      searchForm: {
        currentPage: 1,
        pageSize: 10
      }
    }
  },
  mounted() {
    this.tableText = this.$t('collectDetail')
    this.getData()
  },
  methods: {
    getData() {
      this.loading = true
      queryFlowHistory(this.searchForm, this.$route.query.orderId)
        .then(res => {
          this.loading = false
          if (res.success) {
            this.tableData = res.data
            this.totalNumber = res.page ? res.page['totalNumber'] : 0
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error(err.message)
        })
    },
    handleSizeChange(val) {
      this.searchForm.pageSize = val
      this.getData()
    },
    handleCurrentChange(val) {
      this.searchForm.currentPage = val
      this.getData()
    }
  }
}
</script>

<style scoped>

</style>
